#include <iostream>

using namespace std;

const int N = 1010;

int a[N][N];
int n;

void print()
{
	for (int i = 0; i < n; i ++ )
	{
		for (int j = 0; j < n; j ++ ) cout << a[i][j] << ' ';
		puts("");
	}
}

int main()
{
	cin >> n;
	
	for (int i = 0; i < n - 1; i ++ )
	{
		for (int j = 0; j < n - 1; j ++ )
		{
			a[i][j] = ((i + j) % (n - 1) + 1);
		}
	}
	
	for (int i = 0; i <= n - 1; i ++ )
	{
		a[i][n - 1] = a[n - 1][i]  = a[i][i];
		a[i][i] = 0;
	}
	
	print();
	return 0;
}